using System.Collections;
using System.Collections.Generic;
using OrderSystem;
using PureMVC.Interfaces;
using PureMVC.Patterns;
using UnityEngine;

/// <summary>
/// 客人到店/离店命令类，负责处理客人添加和移除相关业务逻辑
/// 继承自PureMVC的SimpleCommand，协调客户代理完成客人信息管理
/// </summary>
public class GuestBeAwayCommed : SimpleCommand
{
    /// <summary>
    /// 执行命令，根据通知类型处理客人到店或离店操作
    /// </summary>
    /// <param name="notification">包含客人信息的通知对象，Type属性指定操作类型：
    /// - "Add": 客人到店，添加新客户并初始化状态和人数
    /// - "Remove": 客人离店，从系统中移除客户
    /// </param>
    public override void Execute(INotification notification)
    {
        base.Execute(notification);
        ClientProxy clientProxy = Facade.RetrieveProxy(ClientProxy.NAME) as ClientProxy;
        if (notification.Type == "Add")
        {
            ClientItem client = notification.Body as ClientItem;
            client.state = 0;
            client.population = Random.Range(3, 14);
            clientProxy.AddClient(client);
        }
        else if (notification.Type == "Remove")
        {
            clientProxy.DeleteClient(notification.Body as ClientItem);
        }
    }
}
